﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using com.lover.astd.common.config;
using com.lover.astd.common.model;
using com.lover.astd.common.model.enumer;
using com.lover.astd.common;

namespace com.lover.astd.game.ui.server.impl.battle
{
    /// <summary>
    /// 盛宴活动
    /// </summary>
    class KfBanquetServer : LogicServer
    {
        public KfBanquetServer(MainForm frm) { _mainForm = frm; ServerName = ConfigStrings.S_KfBanquet; ServerReadableName = ConfigStrings.SR_KfBanquet; }
        public override void renderSettings()
        {
            MainForm frm = _mainForm;
            Dictionary<string, string> conf = getConfig(ServerName);
            frm.chk_kf_banquet_enabled.Checked = conf.ContainsKey(ConfigStrings.enabled) && conf[ConfigStrings.enabled].ToLower().Equals("true");
            frm.chk_kf_banquet_single.Checked = conf.ContainsKey(ConfigStrings.single) && conf[ConfigStrings.single].ToLower().Equals("true");
            if (conf.ContainsKey(ConfigStrings.buygold))
            {
                int v = 0;
                Int32.TryParse(conf[ConfigStrings.buygold], out v);
                frm.num_kf_banquet_buygold.Value = v;
            }
        }
        public override void saveSettings()
        {
            MainForm frm = _mainForm;
            GameConfig conf = getConfig();
            conf.setConfig(ServerName, ConfigStrings.enabled, frm.chk_kf_banquet_enabled.Checked.ToString());
            conf.setConfig(ServerName, ConfigStrings.single, frm.chk_kf_banquet_single.Checked.ToString());
            conf.setConfig(ServerName, ConfigStrings.buygold, frm.num_kf_banquet_buygold.Value.ToString());
        }
        public override void loadDefaultSettings()
        {
            GameConfig conf = getConfig();
            conf.setConfig(ServerName, ConfigStrings.enabled, "true");
            conf.setConfig(ServerName, ConfigStrings.single, "false");
            conf.setConfig(ServerName, ConfigStrings.buygold, "0");
            renderSettings();
        }
    }
}
